<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('新增url路径')"/>
</head>

<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-url-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">URL路径</label>
            <div class="col-sm-8">
                <input name="url" class="form-control" required style="margin-bottom: 5px;"
                       placeholder="例：/v1/{path}/category/{path}/product" value="/"/>
                <span style="color: red;font-weight: 700;">※ URL路径以/开始，如果有Path传参情况，请用占位符{path}占位</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">名称：</label>
            <div class="col-sm-8">
                <input name="name" class="form-control" type="text" required maxlength="150">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <textarea name="description" class="form-control" type="text" maxlength="255"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
        var prefix = ctx + "system/url"
        $("#form-url-add").validate({
            focusCleanup: true,
            rules: {
                url: {
                    maxlength: 500,
                    remote: {
                        url: prefix + `/check`,
                        data : {
                            "url": function() {
	                            return $.common.trim($("[name='url']").val());
	                        }
                        },
                        dataType: "json",
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                }
            },
            messages: {
	            "url": {
	                remote: "URL已存在"
	            }
	        }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-url-add').serialize());
            }
        }

</script>
</body>

</html>